﻿// CGridCellProp.cpp: 实现文件
//
#include "pch.h"
#include "StudentSystem.h"
#include "CGridCellProp.h"
#include "afxdialogex.h"
#include"CMyDialog1.h"
// CGridCellProp 对话框

IMPLEMENT_DYNAMIC(CGridCellProp, CPropertyPage)
extern array<vector<int>, 7> repeatLec;
extern map<int, CLecture> Lecture;
int totHandle = 0;
CGridCellProp::CGridCellProp(CWnd* pParent /*=nullptr*/)
	: CPropertyPage(IDD_PROPPAGE_LARGE)
{
}

CGridCellProp::~CGridCellProp()
{
}

void CGridCellProp::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_START_TIME, m_limitHourEdit);
	DDX_Control(pDX, IDC_START_TIME2, m_limitMinEdit);
	DDX_Control(pDX, IDC_END_TIME, m_limitHourEdit2);
	DDX_Control(pDX, IDC_END_TIME2, m_limitMinEdit2);
}


BOOL CGridCellProp::OnInitDialog() {
	SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
	CString str1, str2, str3, str4;
	str1.Format(_T("%d"), startMin / 60);
	str2.Format(_T("%d"), startMin % 60);
	str3.Format(_T("%d"), endMin / 60);
	str4.Format(_T("%d"), endMin % 60);
	GetDlgItem(IDC_START_TIME)->SetWindowTextA(str1);
	GetDlgItem(IDC_START_TIME2)->SetWindowText(str2);
	GetDlgItem(IDC_END_TIME)->SetWindowText(str3);
	GetDlgItem(IDC_END_TIME2)->SetWindowText(str4);
	GetDlgItem(IDC_LEC_NAME)->SetWindowTextA(name);
	return CPropertyPage::OnInitDialog();
}


BEGIN_MESSAGE_MAP(CGridCellProp, CPropertyPage)
	ON_COMMAND(IDOK, &CGridCellProp::OnOK)
	ON_COMMAND(IDCANCEL, &CGridCellProp::OnCancel)
END_MESSAGE_MAP()

void CGridCellProp::OnOK() { //单击确定后的操作。
	CString str1, str2, str3, str4, strName;
	GetDlgItem(IDC_START_TIME)->GetWindowTextA(str1);
	GetDlgItem(IDC_START_TIME2)->GetWindowText(str2);
	GetDlgItem(IDC_END_TIME)->GetWindowText(str3);
	GetDlgItem(IDC_END_TIME2)->GetWindowText(str4);
	GetDlgItem(IDC_LEC_NAME)->GetWindowText(strName);
	startMin = _ttoi(str1) * 60 + _ttoi(str2);
	endMin = _ttoi(str3) * 60 + _ttoi(str4);
	if (handle >= 0) { // 进行修改操作。
		CLecture* pLec = &Lecture[handle];
		pLec->setStartTime(startMin);
		pLec->setEndTime(endMin);
		pLec->setName(name);
	}
	else {//进行增添操作。
		Lecture[++totHandle] = CLecture();
		CLecture* pLec = &Lecture[totHandle];
		pLec->setStartTime(startMin);
		pLec->setEndTime(endMin);
		pLec->setName(strName);
		pLec->setHandle(totHandle);
		repeatLec[week].push_back(pLec->getHandle());
	}
}

void CGridCellProp::OnCancel() {


}
// CGridCellProp 消息处理程序



